<template>
  <div>
    <el-dropdown trigger="click"
                 @command="handleSetSize">
      <div class="size-icon--style">
        <svg-icon class-name="size-icon"
                  icon-class="language" />
      </div>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item v-for="item of sizeOptions"
                            :key="item.value"
                            :disabled="langVal === item.value"
                            :command="item.value">
            {{ item.label }}
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script setup>
import i18n from '@/locales/i18n'

const langVal = ref('zh')
const sizeOptions = ref([
  { label: '英文', value: 'en' },
  { label: '中文', value: 'zh' },
])

function handleSetSize(lang) {
  // proxy.$modal.loading('正在设置布局大小，请稍候...')
  langVal.value = lang
  localStorage.setItem('language', lang)
  i18n.global.locale.value = lang
  // setTimeout('window.location.reload()', 1000)
}
</script>

<style lang='scss' scoped>
.size-icon--style {
  font-size: 18px;
  line-height: 50px;
  padding-right: 7px;
}
</style>